﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BOSS.Framework.Search.UrlBuilder;

namespace BOSS.Framework.Search.Context
{
    /// <summary>
    /// 排序条件部分
    /// </summary>
    [Serializable]
    public class SortPart : ISortPart
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="descend"></param>
        public SortPart(string fieldName, bool descend)
        {
            this.FieldName = fieldName;
            this.Descend = descend;
        }

        #region IQueryPart 成员

        /// <summary>
        /// 获取 字段名称
        /// </summary>
        public string FieldName { get; private set; }

        /// <summary>
        /// 构造 URL
        /// </summary>
        /// <param name="urlBuilder"></param>
        public void BuildUrl(IUrlBuilder urlBuilder)
        {
            urlBuilder.SetSort(this.FieldName, this.Descend);
        }

        #endregion

        #region ISortPart 成员

        /// <summary>
        /// 获取 / 设置 是否降序排列
        /// </summary>
        public bool Descend { get; set; }

        #endregion
    }
}
